FROM php:8.2.27-fpm-bookworm

RUN sed -i "s@http://\(deb\|security\).debian.org@https://mirrors.aliyun.com@g" /etc/apt/sources.list.d/debian.sources \
	&& apt-get update && apt-get install -y \
		libfreetype-dev \
		libjpeg62-turbo-dev \
		libpng-dev \
		libzip-dev \
	&& rm -rf /var/lib/apt/lists/* \
	# 生产环境用这个配置
	# && mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
	&& mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" \
	&& docker-php-ext-configure gd --with-freetype --with-jpeg \
	&& docker-php-ext-install -j$(nproc) gd zip mysqli pdo pdo_mysql bcmath calendar gettext opcache pcntl \
	&& pecl install redis-6.1.0 \
	&& pecl install xdebug-3.2.1 \
	&& docker-php-ext-enable redis xdebug \
	&& docker-php-source delete \
	&& php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" \
	&& php composer-setup.php \
	&& php -r "unlink('composer-setup.php');" \
	&& mv composer.phar /usr/local/bin/composer \
	&& composer config -g repo.packagist composer https://packagist.phpcomposer.com

COPY conf/docker-php-ext-* /usr/local/etc/php/conf.d/
COPY conf/www.conf /usr/local/etc/php-fpm.d/www.conf
COPY conf/php-fpm.conf /usr/local/etc/php-fpm.conf
COPY conf/php.ini /usr/local/etc/php/php.ini
COPY conf/zz-docker.conf /usr/local/etc/php-fpm.d/zz-docker.conf